import axios from 'axios';
import {reactive, onBeforeMount} from 'vue'


export default ()=>{
    
    let dogList = reactive<Array<string>>([
            
    ]);

    // 控制在加载开始前请求先获得一张照片(每个定义的hook都可以定义相同的生命周期)
    onBeforeMount(()=>{
        getDog()
    })
    
    async function getDog() {
       let result = await axios.get('https://dog.ceo/api/breeds/image/random')
       dogList.push(result.data.message)
    }

    return {dogList, getDog}
}